import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:music_together/business/page/home/home_view.dart';
import 'package:music_together/business/page/local/local_view.dart';
import 'package:music_together/res/colors.dart';

import 'left_navigation_bar_logic.dart';

class LeftNavigationBarComponent extends StatelessWidget {
  LeftNavigationBarComponent({Key? key}) : super(key: key);

  final logic = Get.find<LeftNavigationBarLogic>();

  @override
  Widget build(BuildContext context) {
    return Obx(() => NavigationView(
          // appBar: const NavigationAppBar(
          //     // title: Text("一起听歌吧"),
          //     title: Row(
          //       children: [Text("search Bar")],
          //     )
          //     // leading: Text("wo1"),
          //     ),
          pane: NavigationPane(
              selected: logic.selectedIndex.value,
              onChanged: (index) => logic.onDestinationSelectedHandle(index),
              displayMode: PaneDisplayMode.compact,
              items: buildPaneItem(),
              size: NavigationPaneSize(openWidth: 132.w)),
          // content: Container(
          //   child: Text("789"),
          // )
        ));
  }

  List<NavigationPaneItem> buildPaneItem() {
    List<NavigationPaneItem> items = [
      PaneItem(
          icon: const Icon(FluentIcons.home),
          title: const Text('房间'),
          body: Container(
            child: HomePage(),
          )),
      PaneItem(
          icon: const Icon(FluentIcons.cube_shape),
          title: const Text('本地'),
          body: Container(
            child: LocalPage(),
          ))
    ];
    return items;
  }
}
